#pragma once

#include "net_interface.hpp"

class CClientMgr;

class CClient
{
public:
    CClient(INT32 iPkgSize, CClientMgr* poClientMgr);
    ~CClient(void);

    void OnEstablish(void);
    void OnTerminate(void);
    void OnError(INT32 iModuleError, INT32 iSystemError);
    void OnRecv(const char* pData, const INT32 iLen);
    void SendPkg(void);
    void ReConnect(void);
    void BuildPkg(void);

    inline HSESSION GetSession(void){return m_hSession;}
    inline void SetSession(HSESSION hSession){m_hSession = hSession;}

    void Check(void);

    void FailPkgLog(const char* pData, const INT32 iLen, INT32 iType);
public:
    char*           m_pSendBuf;
    UINT32          m_dwPkgLen;

    INT32           m_iSendBufSize;
    INT32           m_iRecvLimit;
    
    UINT32          m_dwSendPkgIdx;
    UINT32          m_dwRecvPkgIdx;

    //INT32           m_iPkgIdx;
    HSESSION        m_hSession;
    CClientMgr*     m_poClientMgr;
    UINT32          m_dwStarConnectTick;
    bool            m_bEstablish;
    UINT32          m_dwUnRecvSec;
};
